from typing import List
from pydantic_settings import BaseSettings
import secrets


class Config(BaseSettings):
    """应用配置类"""
    
    # 项目配置
    PROJECT_NAME: str = "X-Admin"
    VERSION: str = "1.0.0"
    DESCRIPTION: str = "FastAPI Admin"
    DEBUG: bool = True
    
    # JWT配置
    SECRET_KEY: str = secrets.token_urlsafe(32)
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 # 7 days
    
    # CORS配置
    CORS_ORIGINS: List[str] = [
        "http://localhost:8000",
        "http://localhost:8080",
        "http://localhost:8100",
    ]
    CORS_ALLOW_CREDENTIALS: bool = True
    CORS_ALLOW_METHODS: List[str] = ["*"]
    CORS_ALLOW_HEADERS: List[str] = ["*"]
    
    # 日志配置
    LOG_LEVEL: str = "INFO"
    LOG_FORMAT: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"


# 创建全局配置实例
settings = Config()
